package com.firebroo.Flyweight;

import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class test {
	public static void main(String[] args) throws SQLException,
			UnsupportedEncodingException {
		ConnectionPool connectionPool = ConnectionPool.getInstance();
		Connection connection = connectionPool.getConnection();
		Statement statement = connection.createStatement();
		String sql = "select * from p";
		ResultSet rs = statement.executeQuery(sql);
		String name = null;

		while (rs.next()) {

			// 选择sname这列数据
			name = rs.getString("firstname");

			// 首先使用ISO-8859-1字符集将name解码为字节序列并将结果存储新的字节数组中。
			// 然后使用GB2312字符集解码指定的字节数组
			name = new String(name.getBytes("ISO-8859-1"), "GB2312");

			// 输出结果
			System.out.println(rs.getString("p_id") + "\t" + name);
		}
	}
}
